package model.ability;

/**
 * Class defines the passive skills used to determine the effectiveness
 * of abilities. Assume PassiveSkills typically range from 1-25.
 * @author Zachary
 */
public class PassiveSkill implements Cloneable{
	private String name;
	private int level;
	private static final int MAXLEVEL = 25;
	
	/**
	 * Constructor for a PassiveSkill starting with a default skill level.
	 * @param name
	 */
	public PassiveSkill(String name){
		this.name = name;
		this.level = 1;
	}
	
	/**
	 * Constructor for a PassiveSkill defining all attributes.
	 * @param name
	 * @param level
	 */
	public PassiveSkill(String name, int level){
		this.name = name;
		this.level = Math.min(level, MAXLEVEL);
	}

	/**
	 * Increments level by one.
	 */
	public void levelUp(){
		if(this.level < MAXLEVEL)
			++this.level;
	}
	
	/**
	 * Changes level by the modifier.
	 * @param modifier
	 */
	public void modifyLevel(int modifier){
		int newLevel = this.level + modifier;
		if(newLevel > MAXLEVEL)
			this.level = MAXLEVEL;
		else if(newLevel < 1)
			this.level = 1;
		else
			this.level = newLevel;
	}

	public String getName() {
		return this.name;
	}

	public int getLevel() {
		return this.level;
	}
	
	public int getMAXLEVEL(){
		return MAXLEVEL;
	}

	@Override
	public PassiveSkill clone() throws CloneNotSupportedException {
		// TODO Auto-generated method stub
		return (PassiveSkill)super.clone();
	}
}
